﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Mail;

namespace MobileBroadbandLoggingMonitor.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {

        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            string msg = "\n\nURL:\n " + Request.QueryString.ToString() + "\n\nMESSAGE:\n " + Server.GetLastError().Message + "\n\nSTACK TRACE:\n" + Server.GetLastError().InnerException.StackTrace;

            MailMessage mailMsg = new MailMessage();
            mailMsg.To = "christer.dk@gmail.com";
            mailMsg.From = "christer.dk@gmail.com";
            mailMsg.Subject = "Application Error";
            mailMsg.Body = msg;

            SmtpMail.SmtpServer = "mailout1.surf-town.net";
            SmtpMail.Send(mailMsg);
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}